package de.tum.in.eist.im.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.VerticalPanel;


 
/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class EIST_IM implements EntryPoint {
	
	// attributes
	private ChatServiceAsync chatSvc = (ChatServiceAsync)GWT.create(ChatService.class);
	private UserListView userListView;
	private LoginDialog loginView;
	//private Messaging messaging;
	//private Chathistory chathistory;		
	
	@Override
	public void onModuleLoad() {
		loginView = new LoginDialog(chatSvc);
		loginView.show(new AsyncCallback<Void>() {
			public void onFailure(Throwable arg0) {}
			public void onSuccess(Void arg0) {
				// dieser Codeblock wird ausgeführt, sobald sich der Nutzer erfolgreich eingeloggt hat:
				
				// hier können MesssageHistoryView und SendMessageView initialisiert werden (daten laden, usw), genau wie UserListView:
				userListView = new UserListView(chatSvc);
				RootPanel.get("user-list-container").add(userListView.getUserListWidget());
			}
			
		});

		
		// FlexTable for Chathistory
	    // Tables have no explicit size -- they resize automatically on demand.
	    FlexTable t = new FlexTable();
	    t.addStyleName("Chathistory");
	    t.setText(0, 0, "Chathistory:");
	    t.setText(170, 130, "");
	    RootPanel.get().add(t);
	  
		    
	    // TextArea to send a message 
	    TextArea ta1 = new TextArea();
	    ta1.addStyleName("TextAreaColour");
	    ta1.setCharacterWidth(100);
	    ta1.setVisibleLines(5);
	    // Add them to the root panel.
	    VerticalPanel panel11 = new VerticalPanel();
	    panel11.add(ta1);
	    RootPanel.get().add(panel11);    
	    // Add them to the root panel.
	    VerticalPanel panel111 = new VerticalPanel();
	    RootPanel.get().add(panel111);
	    
	    	
	    
	    // Button to send a message
	    Button b1 = new Button("Send Message!");
	    b1.addClickHandler(new ClickHandler(){

			@Override
			public void onClick(ClickEvent arg0) {
				
			}
			
	    });

	    // Add it to the root panel.
	    RootPanel.get().add(b1);
	
		
	}
// testtest
	
}